package com.plian.system.dao.pm.property;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import com.plian.system.dto.pm.property.PropertyChangeDTO;
import com.plian.system.model.page.Page;
import com.plian.system.vo.pm.property.EconomicBehaviorCountVO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class PropertyDao {
    @Resource(name = "daoSupport")
    private DaoSupport dao;

    /**
     * 新增
     * @param pd
     * @throws Exception
     */
    public void save(PageData pd) throws Exception {
        dao.save("PropertyMapper.save",pd);
    }

    /**
     * 修改
     * @param pd
     * @throws Exception
     */
    public void edit(PageData pd) throws Exception {
        dao.update("PropertyMapper.edit",pd);
    }

    /**
     * * 根据Id获取最新的一条数据
     * @param id
     * @return
     * @throws Exception
     */
    public PageData findbyid(String id) throws Exception {
        return (PageData) dao.findForObject("PropertyMapper.findbyid",id);
    }

    /**
     * 根据orgId获取最新的一条数据
     * @return
     * @throws Exception
     */
    public PageData findByorgId(String orgId) throws Exception {
        return (PageData) dao.findForObject("PropertyMapper.findByorgId",orgId);
    }

    public PageData findByDataSourceId( PageData pd) throws Exception {
        return (PageData) dao.findForObject("PropertyMapper.findByOrgCode",pd);
    }


    public void del_ids(List<String> ids) throws Exception {
        dao.delete("PropertyMapper.del_ids",ids);
    }

    /**
     * 修改状态
     * @param pd
     */
    public void  refer(PageData pd) throws Exception {
        dao.update("PropertyMapper.refer",pd);
    }
    /**
     * 修改状态
     * @param pd
     */
    public List<PageData> findByIds(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyMapper.findByIds",pd);
    }

    /**
     * 根据多单位查询列表
     * @param page
     * @return
     * @throws Exception
     */
    public List<PageData> reportListPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyMapper.reportListPage",page);
    }
    public List<PageData> list(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyMapper.list",pd);
    }
    public List<PageData> listPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyMapper.listPage",page);
    }
    public void editByOrgId(PageData pd) throws Exception {
        dao.update("PropertyMapper.editByOrgId",pd);
    }
    public void editByOrgIdAll(List<PageData> list) throws Exception {
        dao.update("PropertyMapper.editByOrgIdAll",list);
    }

    public List<EconomicBehaviorCountVO> situationCount(PropertyChangeDTO propertyChangeDTO) throws Exception {
        return (List<EconomicBehaviorCountVO>) dao.findForList("PropertyMapper.situationCount",propertyChangeDTO);
    }
    /**
            * 根据id串获得分类汇总表数据
     */
    public PageData listByid(PageData pd) throws Exception {
        return (PageData) dao.findForObject("PropertyMapper.listByid",pd);
    }
    /**
     * 根据orgid获得id
     */
    public PageData listidByorg(PageData pd) throws Exception {
        return (PageData) dao.findForObject("PropertyMapper.listidByorg",pd);
    }


    public List<PageData> findByFillOrgIdPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyMapper.findByFillOrgIdPage",page);
    }

    public void updateOrgCode(List<PageData> list) throws Exception {
        dao.batchSave("PropertyMapper.updateOrgCode",list);
    }

    public List<PageData> noApprovalList(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyMapper.noApprovalList",pd);
    }
}
